//
//  ZJHelpWebController.m
//  Lottery
//
//  Created by ZJ on 2018/8/16.
//  Copyright © 2018年 iCatch Technology Inc. All rights reserved.
//

#import "ZJHelpWebController.h"

@interface ZJHelpWebController () <UIWebViewDelegate>

@end

@implementation ZJHelpWebController

// 把控制器 view 变成 WebView
- (void)loadView {
    self.view = [[UIWebView alloc] initWithFrame:kScreenSize];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    // 加载网页
    UIWebView *webView = (UIWebView *)self.view;
    
    // 设置代理
    webView.delegate = self;
    
    // 创建 url 对象
    NSURL *url = [[NSBundle mainBundle] URLForResource:self.help.html withExtension:nil];
    // 通过一个统一资源定位符 包装成一个请求
    NSURLRequest *req = [[NSURLRequest alloc] initWithURL:url];
    
    // 加载请求
    [webView loadRequest:req];
}

// 网页加载完成调用
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    // 代码
    NSString *code = [NSString stringWithFormat:@"document.location.href = '#%@'", self.help.ids];
    
    [webView stringByEvaluatingJavaScriptFromString:code];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
